package practice;
import java.util.Scanner;
public class ApiDemo {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String code1 = "abcdefghijklmnopqrstuvwxyz";
        String code2 = code1.toUpperCase();
        String code3 = "0123456789";
        String code = code1+code2+code3;
        System.out.println(code);

        while(true) {
            String myCode = "";
            for(int i=1;i<=4;i++) {
                int index = (int) (Math.random() * code.length());
                char a = code.charAt(index);
                myCode += a;
            }
            System.out.println(myCode);
            myCode = myCode.toUpperCase();
            System.out.print("请输入验证码：");
            String input = scan.nextLine();
            input = input.toUpperCase();
            if(input.equals(myCode)) {
                System.out.println("输入正确！");
                break;
            } else {
                System.out.println("输入错误！");
                continue;
            }
        }
    }
}
